package com.gw.quotes.activity.fragment;

import net.tsz.afinal.FinalActivity;
import net.tsz.afinal.annotation.view.ViewInject;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import com.gw.quotes.R;
import com.gw.quotes.activity.PriceInfoActivity;
import com.gw.quotes.constant.Constant;
import com.gw.quotes.entity.business.Priceinfo;

/**
 * 2014-10-22 下午7:26:45
 * 
 * 商品介绍
 */
public class GoodsFragment4 extends Fragment {

	private View contextView = null;

	private static String url = "http://" + Constant.SERVER_IP + "/gposinterface/getGoodsContent.do?goodscode=";

	@ViewInject(id = R.id.f4_webview)
	private WebView webview;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (contextView == null) {
			contextView = inflater.inflate(R.layout.fragment_activity_goods4, null);
		}
		ViewGroup parent = (ViewGroup) contextView.getParent();
		if (parent != null) {
			parent.removeView(contextView);
		}
		FinalActivity.initInjectedView(this, contextView);
		initView();
		return contextView;
	}

	private void initView() {
		StringBuffer html = new StringBuffer();
		Priceinfo priceinfo = ((PriceInfoActivity) getActivity()).getPriceinfo();
		String goodsCode = priceinfo.getGoodscode();
		// webview.getSettings().setDefaultTextEncodingName("utf-8");
		// goodsCode = "59000";
		webview.loadUrl(url + goodsCode);
	}
}
